package com.zr.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.transform.Transformers;
import org.springframework.stereotype.Repository;

import com.zr.dao.ProxyDao;
import com.zr.model.Point_psfw_vo;
@Repository("proxydao")
public class ProxyDaoImpl extends BaseDaOImpl implements ProxyDao{

	@Override
	public List<Point_psfw_vo> findAllProxys(int page, int rows) {
		String sql = "SELECT point.pid,psfwb.did,psfwb.dname,psfwb.uid,point.pname from point,psfwb where point.pid=psfwb.pid";
		Query query = this.getCurrentSession().createSQLQuery(sql);
		query.setFirstResult((page-1)*rows);
    	query.setMaxResults(rows);
        List<Point_psfw_vo> l = query.setResultTransformer(Transformers.aliasToBean(Point_psfw_vo.class)).list();
		return l;
	}

	@Override
	public long countAllProxys() {
		String hql = "select count(*) from Psfwb";
		List<Object>  obj = this.getCurrentSession().createQuery(hql).list();
		return (long)obj.get(0);
	}

}
